// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env:'mupp-5gs2863z7cf6873f'
})

// 云函数入口函数
exports.main = async (event, context) => {
    const wxContext = cloud.getWXContext()
    const db=cloud.database()
    const shopComment=db.collection('shopComment')
    const _=db.command
    let openid=wxContext.OPENID
    if(event.up){
        shopComment.where({
            _id:event._id
        }).update({
            data:{
                zan:_.push(openid)
            }
        })
    }else{
        shopComment.where({
            _id:event._id
        }).update({
            data:{
                zan:_.pull(openid)
            }
        })
    }
        
    return {
        
    }
}